<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets">
    <ui:composition template="/template/principal.xhtml">
        <ui:define name="conteudo">
            <h:form>
                <p:panel header="ImageCropper com FileUpload - QuebrandoParadigmas.com" style="width: 900px; margin: 0 auto; margin-top: 0px">
                    <p:fileUpload fileUploadListener="#{indexManagedBean.enviarImagem}" sizeLimit="204800" auto="true"
                                  image="/imagens/imgBuscar.png" customUI="true" update="outputPanelUpload"/>
                    <p:outputPanel id="outputPanelUpload">
                        <h:panelGrid columns="2">
                            <h:outputText value="Imagem" rendered="#{indexManagedBean.exibeBotao}"/>
                            <h:outputText value="Pre-visualização" rendered="#{indexManagedBean.exibeBotao}"/>
                            <p:imageCropper id="imageCropperImagemTemporaria" value="#{indexManagedBean.croppedImage}"
                                            image="#{pageContext.servletContext.contextPath}/upload/#{indexManagedBean.imagemTemporaria}"/>
                            <p:graphicImage value="#{indexManagedBean.imagemEnviada}" cache="false"/>
                        </h:panelGrid>
                        <p:commandLink action="#{indexManagedBean.crop}" update="outputPanelUpload"
                                       rendered="#{indexManagedBean.exibeBotao}">
                            <p:graphicImage style="margin-top: 5px; border: none;" value="/imagens/imgCortar.png"/>
                        </p:commandLink>
                    </p:outputPanel>
                </p:panel>
            </h:form>
        </ui:define>
    </ui:composition>
</html>
